/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TrinmaalAdminPanel.java
 *
 * Created on May 11, 2012, 1:06:15 AM
 */
package view;

/**
 *
 * @author Marc
 */
public class TrinmaalAdminPanel extends javax.swing.JPanel {

    /** Creates new form TrinmaalAdminPanel */
    public TrinmaalAdminPanel() {
    
        initComponents();
        
        jTextField2.setEnabled(false);
        jComboBox1.setEnabled(false);
        jComboBox2.setEnabled(false);
        jButton1.setEnabled(false);
        jButton2.setEnabled(false);
        jButton4.setEnabled(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jTextField2 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();

        setLayout(null);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Fag", "Årgang", "Trinmål"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jTable1.getTableHeader().setReorderingAllowed(false);
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(0).setMinWidth(150);
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(150);
        jTable1.getColumnModel().getColumn(0).setMaxWidth(150);
        jTable1.getColumnModel().getColumn(1).setMinWidth(75);
        jTable1.getColumnModel().getColumn(1).setPreferredWidth(75);
        jTable1.getColumnModel().getColumn(1).setMaxWidth(75);

        add(jScrollPane1);
        jScrollPane1.setBounds(20, 40, 860, 410);

        jLabel1.setText("Eksisterende trinmål:");
        add(jLabel1);
        jLabel1.setBounds(20, 20, 160, 14);

        jButton1.setText("Rediger");
        add(jButton1);
        jButton1.setBounds(900, 50, 100, 40);

        jButton2.setText("Slet trinmål");
        add(jButton2);
        jButton2.setBounds(900, 120, 100, 40);

        jButton3.setForeground(new java.awt.Color(255, 0, 0));
        jButton3.setText("SLET ALLE");
        add(jButton3);
        jButton3.setBounds(900, 290, 100, 23);

        jLabel2.setText("Tilføj Trinmål:");
        add(jLabel2);
        jLabel2.setBounds(20, 480, 130, 14);

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });
        add(jTextField1);
        jTextField1.setBounds(40, 500, 60, 20);

        jLabel3.setText("ID");
        add(jLabel3);
        jLabel3.setBounds(20, 500, 20, 14);

        jLabel4.setText("Fag");
        add(jLabel4);
        jLabel4.setBounds(130, 500, 34, 14);

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Matematik", "Dansk", "Engelsk", "Fysik" }));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });
        add(jComboBox1);
        jComboBox1.setBounds(160, 500, 130, 20);

        jLabel5.setText("Årgang");
        add(jLabel5);
        jLabel5.setBounds(320, 500, 60, 14);

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0. Klasse", "1. Klasse", "2. Klasse", "3. Klasse", "4. Klasse", "5. Klasse", "6. Klasse", "7. Klasse", "8. Klasse", "9. Klasse", "10. Klasse", " " }));
        jComboBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox2ActionPerformed(evt);
            }
        });
        add(jComboBox2);
        jComboBox2.setBounds(370, 500, 90, 20);

        jTextField2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField2ActionPerformed(evt);
            }
        });
        add(jTextField2);
        jTextField2.setBounds(530, 500, 360, 20);

        jLabel6.setText("Trinmål");
        add(jLabel6);
        jLabel6.setBounds(490, 500, 70, 14);

        jButton4.setText("Gem");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        add(jButton4);
        jButton4.setBounds(910, 500, 80, 23);
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        jComboBox2.setEnabled(true);
    }//GEN-LAST:event_jComboBox1ActionPerformed

    private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
        jTextField2.setEnabled(true);
    }//GEN-LAST:event_jComboBox2ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed

        
        // EFTER den har gemt trinmaal
        jTextField1.setText("");
        jTextField2.setText("");
        jTextField2.setEnabled(false);
        jComboBox1.setEnabled(false);
        jComboBox2.setEnabled(false);
        jButton4.setEnabled(false);
        
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
        
        System.out.println("sup");
        System.out.println(jTable1.getSelectedRow());
        jButton1.setEnabled(true);
        jButton2.setEnabled(true);
        
        
    
    }//GEN-LAST:event_jTable1MouseClicked

    private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
        jButton4.setEnabled(true);
    }//GEN-LAST:event_jTextField2ActionPerformed

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed

        if (!jTextField1.getText().equalsIgnoreCase("")) {             jComboBox1.setEnabled(true);         }     }//GEN-LAST:event_jTextField1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    // End of variables declaration//GEN-END:variables
}
